<!-- create begin -->
<div class=" create">
   
    <!-- 表单 -->   
    <section class="panel-body">
            <form role="form" class="form-create">

                <div class="form-group col-sm-6">
                    <span>名称</span>
                    <input type="text" class="form-control" placeholder="名称" name="name" autocomplete="off">
                </div>

                <div class="form-group col-sm-6">
                    <span>图标</span> <a href="http://fontawesome.dashgame.com" target="_blank"> 查看图标 </a>
                    <input type="text" class="form-control" placeholder="图标" name="ico" autocomplete="off">
                </div>

                <div class="form-group col-sm-12">
                    <span>上级</span>
                    <select class="form-control" name="pid" placeholder="上级">
                        <option value="0">全部</option>
                        {volist name="list" id="vo"}
                            {if($vo.level<2) }
                                <option value="{$vo.id}" {:input('pid')==$vo.id ? 'selected="selected"' : null } >
                                    {:$vo.level>0? '|' : null }{:str_repeat('--',$vo.level)}{$vo.name}
                                </option>
                            {else /} {/if}

                        {/volist}
                    </select>
                </div>

                <div class="form-group col-sm-6">
                    <span>控制器</span>
                    <input type="text" class="form-control" placeholder="控制器" name="controller" autocomplete="off">
                </div>

                <div class="form-group col-sm-6">
                    <span>方法</span>
                    <input type="text" class="form-control" placeholder="方法" name="action" autocomplete="off">
                </div>

                <div class="form-group col-sm-12">
                    <span>状态</span>
                    <div class="radio">
                        <label><input type="radio" name="status" value="0" checked="checked">正常</label>
                    </div>
                    <div class="radio">
                        <label><input type="radio" name="status" value="1" >禁用</label>
                    </div>
                </div>

                <div class="form-group col-sm-12">
                    <span>备注</span>
                    <textarea class="form-control" cols="5" name="desc"></textarea>
                </div>

            </form>
    </section>

    <div class="form-group col-sm-12 panel-footer bg-none">
        <button type="button" class="btn btn-sm btn btn-primary" @click="save">  保 存 </button>
        <button type="reset" class="btn btn-sm btn-success ">  重 置 </button> 
    </div>


</div>
<!-- create end-->


<script>
// function save(){
//     var param = $(".form-create").serializeArray();
//     $.post("{:url('save')}", param, function(data) {
//         if( data.error >0 ){
//           toastr.error(data.msg);
//         }else{
//             show_loading_bar(100);
//             toastr.success(data.msg);
//             Table.methods.refresh();
//             layer.closeAll('page');
//         }
//     },'json');
// }

// seajs
seajs.use([], function() {
    // vue
    var create = new Vue({
        el: '.create',
        data: {},
        mounted: function (){
        },
        methods: {
            save: function () {
                var param = $('.form-create').serializeArray();
                $.ajax({
                    url: "{:url('save')}",
                    method: 'POST',
                    dataType: 'json',
                    data: param,
                    success: this.callback
                });
            },
            callback:function (data) {
                if( data.error >0 ){
                    toastr.error(data.msg);
                }else{
                    toastr.success(data.msg);
                    Table.methods.refresh();
                    layer.closeAll('page');
                }
            }
        }

    });    
        
});

</script>